home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000 #2
/
Ham Radio 2000 - Volume 2.iso
/
HAMV2
/
MISC
/
DL4FBI
/
BEACONS.BAS
< prev
next >
Wrap
BASIC Source File
|
1997-08-15
|
8KB
|
232 lines
DECLARE SUB READPARAMETER ()
DECLARE SUB TIMESET ()
DECLARE SUB MYTIMESET ()
DECLARE SUB PHONETIMESET ()
DECLARE SUB PREPARETS870 ()
DECLARE SUB SCANBEACONS ()
DEFINT A-Z: OPTION BASE 1
DIM signa(5, 18) AS INTEGER 'signalstrength (frequency,station)
DIM t(5, 18) AS STRING 'time of sample HH:MM:SS
DIM sig(10) AS INTEGER 'signalstrengths in 3rd second of transmission
DIM cals(18) AS STRING 'callsigns of the beacons
DIM qth(18) AS STRING 'locations of the beacons
DIM qrg(5) AS STRING 'frequencies in Hz
DIM kom(10) AS STRING 'commands for TS870
DIM pri(5, 18) AS STRING 'string for print of results
DIM sn(5, 18) AS INTEGER 'noise strength
DIM comz(1) AS STRING
SHARED signa(),t(),sig(),cals(),qth(),qrg(),kom(),pri(),sn(),comz()
'end dim and definitions
CALL READPARAMETER 'read the parameterfile C:\BEACON.PAR
CALL PREPARETS870 'identify TS870 and set global parameters
SELECT CASE kom(5)
CASE "1"
CALL TIMESET 'set PC's seconds timer to UTC or local time by DCF 1)
CASE "2"
CALL MYTIMESET 'GPS or WWVB must be installed
CASE "3"
CALL PHONETIMESET 'timeset by phone time signals
END SELECT
CALL SCANBEACONS 'scanning the beacons
SELECT CASE kom(4) 'type of output
CASE "1" 'screen only
CASE "3" 'screen and hardcopy
FOR i = 1 TO 5: FOR j = 1 TO 18
LPRINT ; pri(i, j)
NEXT j: NEXT i
CASE "5"'screen and ASCII-file
OPEN "a:\BEACON.TXT" FOR OUTPUT AS #3
FOR i = 1 TO 5: FOR j = 1 TO 18
WRITE #3, pri(i, j)
NEXT j: NEXT i: CLOSE 3
CASE "7" 'screen and hardcopy and ASCII-file
OPEN "a:\BEACON.TXT" FOR OUTPUT AS #4
FOR i = 1 TO 5: FOR j = 1 TO 18
LPRINT ; pri(i, j)
WRITE #4, pri(i, j)
NEXT j: NEXT i: CLOSE 4
END SELECT
SYSTEM
SUB MYTIMESET SHARED'//////////////////////////////////////////////////////
CLS:LOCATE 8,2
PRINT;"Missing subprogram <MYTIMESET>. Program aborted":end
'insert a program for GPS or WWVB
END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB PHONETIMESET SHARED'///////////////////////////////////////////////////
SHELL "TIME"
END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB PREPARETS870 SHARED'////////////////////////////////////////////////////
'Definitions
PS$ = "PS1;" 'power on
ID$ = "ID;" 'ID-number (TS870:15)
AI$ = "AI0;" 'AI-number (see Kenwood-manual page 89)
SM$ = "SM;" 'command for reading S-Meter
CW$ = "MD3;" 'command for mode cw
VFO$ = "FR0;" 'rx on VFO a
'Power on and identification of TS870:
IF kom(1)="3" THEN
ida$="ID015;"
ELSE
OPEN comz(1) FOR RANDOM AS #1 'open serial port COM2
PRINT #1, PS$ 'power on
PRINT #1, AI$ 'answer only on request (not automatically)
trash$ = INPUT$(LOC(1), #1) 'clean buffer of serial port
PRINT #1, ID$ 'ask for ID of transceiver
te& = TIMER
WHILE TIMER - te& <= .8: WEND 'wait for answer
ida$ = INPUT$(LOC(1), #1) 'read the answer (time critical!)
PRINT #1, VFO$ 'VFO A, RX
PRINT #1, CW$ 'mode cw
PRINT #1, kom(2) 'antenna number
PRINT #1, kom(3) 'filterbandwidth
CLOSE 1 'close serial port COM2
END IF
IF LEFT$(ida$, 2) = "?;" THEN ida$ = RIGHT$(ida$, 6) 'delete random ?;' s
'sent by TS870 when its processor is busy
IF ida$ = "ID015;" THEN
CLS : LOCATE 8, 2
PRINT ; "transceiver identified ! Program will continue...."
ELSE
CLS : LOCATE 8, 2
PRINT ; "wrong or missing transceiver"
PRINT ; "program aborted"
SLEEP 20
END
END IF
END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB READPARAMETER SHARED'//////////////////////////////////////////////////
OPEN "C:\BEACON.PAR" FOR INPUT AS #1
FOR i = 1 TO 18: INPUT #1, cals(i), qth(i): NEXT i
FOR i = 1 TO 5: INPUT #1, qrg(i): NEXT i
FOR i = 1 TO 10: INPUT #1, kom(i): NEXT i
CLOSE 1
FOR i = 1 TO 5: 'qrg to TS870-format
qrg(i) = "FA000" + qrg(i) + ";": NEXT i
comz(1) = "COM" + LTRIM$(RTRIM$(kom(1))) 'part of command for serial port of PC
comz(1) = comz(1) + ":9600,N,8,1,DS,CS,CD" 'command for serial port of PC
kom(2) = "AN" + LTRIM$(RTRIM$(kom(2))) + ";" 'antenna-command
kom(3) = LEFT$(kom(3), 2)
kom(3) = "FW00" + LTRIM$(RTRIM$(kom(3))) + ";" 'filter bandwidth
END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB SCANBEACONS SHARED'////////////////////////////////////////////////////
SM$ = "SM;" 'command for S-Meter"
CLS : LOCATE 8, 2: PRINT ; "transceiver identified, all O.K. , please wait..."
'scanning stations (j=1 to 18) and frequencies (i=1 to 5):
WHILE FIX(TIMER) MOD 180 <> 0
z = 180 - FIX(TIMER) MOD 180 'time until scanning
IF z = 180 THEN z = 0
LOCATE 9, 2
PRINT ; "synchronization to 3rd minute. "; z; " seconds until start of scan.."
WEND
PRINT ; " synchronization successful. Scan will take 16 minutes from now "
PRINT
FOR i = 1 TO 5 '5 frequencies
FOR j = 1 TO 18 '18 stations
IF j = 1 THEN
IF i > 1 THEN
te& = TIMER
WHILE TIMER - te& < 10: WEND 'time-offset for new frequency
END IF
IF kom(1) <> "3" THEN
OPEN comz(1) FOR OUTPUT AS #1
PRINT #1, qrg(i) ' new frequency
CLOSE 1
END IF
END IF
te& = TIMER
WHILE TIMER - te& <= 3!: WEND 'wait for second no 3 (100 watts-signal)
IF kom(1)="3" THEN
s$=""
FOR k = 1 TO 10
s$=s$+"SM0015;"
te!=TIMER
WHILE TIMER - te!<=.1 : WEND
NEXT k
ELSE
OPEN comz(1) FOR RANDOM AS #1
FOR k = 1 TO 10 'during first 100 watts-signal the S-meter
PRINT #1, SM$ 'will be read 10 times
te! = TIMER 'ask every 0.1 seconds
WHILE TIMER - te! <= .1: WEND
NEXT k
s$ = INPUT$(LOC(1), #1) 'input from buffer
CLOSE
END IF
FOR ii = 1 TO 10
sig(ii) = VAL(MID$(s$, (5 + 7 * (ii - 1)), 2)) 'evalute response
NEXT ii
FOR m = 1 TO 10 'looking for maximum out of array of 10 values
g = sig(m)
FOR n = 1 TO 10
IF g > sig(n) THEN sig(n) = 0
NEXT n
NEXT m
res = 0
FOR l = 1 TO 10
IF sig(l) > 0 THEN res = sig(l) 'found maximum
NEXT l
signa(i, j) = res 'store maximum
tim$ = TIME$ 'time of last signal:t(i, j) = TIME$'time of reception HH:MM:SS
sg$ = STR$(res): sg$ = LTRIM$(RTRIM$(sg$)) 'convert for printing
IF LEN(sg$) = 1 THEN sg$ = "0" + sg$
qrgp$ = MID$(qrg(i), 6, 5)
qrgp$ = LEFT$(qrgp$, 2) + "." + RIGHT$(qrgp$, 3) + " " + "MHz "
zw$ = " " + cals(j) + " " + qth(j) + " " + qrgp$
zw$ = zw$ + " " + tim$ + " " + " S-Meter S/N:" + " " + sg$ + "/"
pri(i, j) = zw$
PRINT ; pri(i, j); 'prints one result to screen
te& = TIMER
WHILE TIMER - te& <= 4: WEND 'wait for 8 th' second
IF kom(1)="3" THEN
snn$="SM0005;"
te! = TIMER
WHILE TIMER-te! <=0.9 : WEND
ELSE
OPEN comz(1) FOR RANDOM AS #1
PRINT #1, SM$'ask for s-noise
WHILE LOC(1) < 7 OR TIMER - te& < 0.9: WEND
snn$ = INPUT$(LOC(1), #1)
sn(i, j) = VAL(MID$(snn$, 5, 2))
CLOSE
END IF
snn$ = LTRIM$(RTRIM$(MID$(snn$, 5, 2)))'noisestrength
IF LEN(snn$) = 1 THEN snn$ = "0" + snn$
PRINT ; snn$
pri(i, j) = pri(i, j) + snn$
WHILE FIX(TIMER) MOD 10 <> 0: WEND 'wait for next sample
NEXT j
NEXT i
END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB TIMESET SHARED'////////////////////////////////////////////////////////
'This subroutine is for setting time by time signals broadcast from DCF77
'which can only received in Europe. Receiver and appropriate software
'must be installed in your computer. Source: Conrad Electronic, Hirschau
'Klaus-Conrad-Strasse 1, D92240 Hirschau, Germany. 1997-catalog page 1032
'order-nr. 975770-99. Price: DM 149.90, kit: DM 119.90 + s/h
SHELL "C:\DCF.EXE"
END SUB'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\